import i18n from '@/lang'

// 标题翻译
export function generateTitle(title) {
  const hasKey = this.$te('route.' + title)

  if (hasKey) {
    // $t :this method from vue-i18n, inject in @/lang/index.js
    const translatedTitle = this.$t('route.' + title)

    return translatedTitle
  }
  return title
}

// 常规翻译
export function ctm(msg) {
  const hasKey = i18n.te(msg)

  if (hasKey) {
    // $t :this method from vue-i18n, inject in @/lang/index.js
    const msg = i18n.t(msg)

    return msg
  }
  return msg
}
